import { defineStore, createPinia } from "pinia";
import piniaPluginPersistedstate from "pinia-plugin-persistedstate";
import piniaPersistConfig from "./piniaPersist";
import { ROUTER_NAME_HOME } from "../route";

export const enum Names {
    StoreName = "NoloStore",
}
export const useNoloStore = defineStore(Names.StoreName, {
    state: () => {
        return {
            keepAliveInclude: [ROUTER_NAME_HOME], //当前缓存的组件

            locationSearch: "",
        };
    },
    actions: {
        setKeepAliveInclude(list: string[]) {
            this.keepAliveInclude = list;
        },

        setLocationSearch(locationSearch: string) {
            this.locationSearch = locationSearch;
        },
    },
    getters: {},
    persist: piniaPersistConfig("GlobalState"),
});

const pinia = createPinia();

// piniaPersist(持久化)
pinia.use(piniaPluginPersistedstate);
export default pinia;
